package com.getinstaliker.screen;

import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Toast;

import com.getinstaliker.activity.SplashFragmentActivity;
import com.getinstaliker.instagram.SessionStore;
import com.getinstaliker.screen.common.BaseGetInstalikerHeaderFragment;
import com.getinstaliker.util.ActionUtil;
import com.instagram.getinstaliker.R;

// TODO: Auto-generated Javadoc
/**
 * The Class MoreFragment.
 */
public class MoreFragment extends BaseGetInstalikerHeaderFragment implements OnClickListener{

	/** The Constant RATE_APP_URL. */
	public static final String RATE_APP_URL 		= "google.com";
	
	/** The Constant TODAY_FREE_APP_URL. */
	public static final String TODAY_FREE_APP_URL 	= "google.com";
	
	/** The Constant TODAY_FREE_GAME_URL. */
	public static final String TODAY_FREE_GAME_URL 	= "google.com";
	
	/* (non-Javadoc)
	 * @see com.getinstaliker.screen.common.BaseFragmentScreen#onCreateContentView(android.view.LayoutInflater, android.view.ViewGroup)
	 */
	@Override
	protected View onCreateContentView(LayoutInflater inflater,
			ViewGroup container) {
		View vContent = inflater.inflate(R.layout.more_screen, container, false);
		vContent.findViewById(R.id.btnSignout).setOnClickListener(this);
		vContent.findViewById(R.id.btnRateApp).setOnClickListener(this);
		vContent.findViewById(R.id.btnTodayFreeGame).setOnClickListener(this);
		vContent.findViewById(R.id.btnTodayApp).setOnClickListener(this);
		vContent.findViewById(R.id.btnDownloadApp).setOnClickListener(this);
		return vContent;
	}

	/* (non-Javadoc)
	 * @see com.getinstaliker.screen.common.BaseGetInstalikerHeaderFragment#getTitleResId()
	 */
	@Override
	protected int getTitleResId() {
		return R.string.more;
	}

	/* (non-Javadoc)
	 * @see android.view.View.OnClickListener#onClick(android.view.View)
	 */
	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.btnSignout:
			signOut();
			break;
		case R.id.btnRateApp:
			rateApp();
			break;
		case R.id.btnTodayFreeGame:
			todayFreeGame();
			break;
		case R.id.btnTodayApp:
			todayApp();
			break;
		case R.id.btnDownloadApp:
			downloadApp();
			break;
		default:
			break;
		}
	}
	
	/**
	 * Sign out.
	 */
	public void signOut(){
		SessionStore.getInstance().resetInstagream();
		getActivity().startActivity(new Intent(getActivity(), SplashFragmentActivity.class));
		getActivity().finish();
	}
	
	/**
	 * Rate app.
	 */
	public void rateApp(){
		ActionUtil.actionBrowse(getActivity(), RATE_APP_URL);
	}
	
	/**
	 * Today free game.
	 */
	public void todayFreeGame(){
		ActionUtil.actionBrowse(getActivity(), TODAY_FREE_GAME_URL);
	}
	
	/**
	 * Today app.
	 */
	public void todayApp(){
		ActionUtil.actionBrowse(getActivity(), TODAY_FREE_APP_URL);
	}
	
	/**
	 * Download app.
	 */
	public void downloadApp(){
		Toast.makeText(getActivity(), "Download an App", Toast.LENGTH_SHORT).show();
	}

}
